using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Templates_ImageDownload : BaseTemplateUserControl
{
    protected override void OnLoad(EventArgs e)
    {
        if (!IsPostBack)
        {
            HyperLink lnkLogin = viewDownload.FindControl("lnkLogin") as HyperLink;
            if (lnkLogin != null)
            {
                lnkLogin.NavigateUrl = string.Concat("~/Login.aspx?ReturnUrl=", ((Acms.AcmsControls.TemplatePage)Page).CurrentUrl);
            }
        }
        base.OnLoad(e);
    }

    public override void DataBind()
    {
        HyperLink lnkDownload = viewDownload.FindControl("lnkDownload") as HyperLink;
        if(lnkDownload != null)
        {
            Acms.Bll.PostControl prop = CurrentPost.FindPostControl("Download");
            if(prop != null)
            {
                Acms.AcmsControls.ImageContentControlProperties properties = prop.GetProperties<Acms.AcmsControls.ImageContentControlProperties>(); 
                if(properties != null)
                {
                    lnkDownload.NavigateUrl = string.Concat("~/File.aspx?Id=", properties.ResourceId.ToString());
                }
            }
        }
    }
}
